package com.itedge.solutionmanager.taskdata.impl.solution;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.validation.constraints.Size;

import org.springframework.format.annotation.DateTimeFormat;

import com.itedge.solutionmanager.domain.impl.Employee;
import com.itedge.infrastructure.taskdata.impl.AbstractTaskDataEntity;

@Entity
@Table(name="SCHED_MEET_TASK_DATA")
public class ScheduleMeetingTaskData extends AbstractTaskDataEntity {
	
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;	

	@Version
    @Column(name = "version")
    private Integer version;
	
	@Size(max = 255)
	@Column(name ="location")
	private String location;
	
    @Size(max = 4000)
    @Column(name = "NOTES")
    private String notes;  
    
	@Column(name="MEETING_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    private Date meetingDate;
	
    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name="MEETING_TASKS_EMPLOYEES",
            joinColumns=@JoinColumn(name="MEETING_TASK_ID"),
            inverseJoinColumns=@JoinColumn(name="EMPLOYEE_ID")
        )
    private Set<Employee> assignedEmployees = new HashSet<Employee>(); 	

	public Set<Employee> getAssignedEmployees() {
		return assignedEmployees;
	}

	public void setAssignedEmployees(Set<Employee> assignedEmployees) {
		this.assignedEmployees = assignedEmployees;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Date getMeetingDate() {
		return meetingDate;
	}

	public void setMeetingDate(Date meetingDate) {
		this.meetingDate = meetingDate;
	}

	@Override
	public Long getId() {
        return this.id;
    }

	public void setId(Long id) {
        this.id = id;
    }	

	@Override
	public Integer getVersion() {
        return this.version;
    }

	@Override
	public void setVersion(Integer version) {
        this.version = version;
    }
}